package projeto1;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;

import java.awt.Font;

import javax.swing.JTextField;
import javax.swing.JButton;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;


public class CadastroLinha2 extends JFrame {

	private JPanel contentPane;
	private JTextField jtfNomeOnibus2;
	private JTextField jtfCodigo2;
	private JTextField jtfEmpresa2;
	private JTextField jtfIntinerario2;
	private JButton btnConfirmar;
	private JLabel lblNewLabel;
	private JButton btnRemover;
	private JButton btnAnterior;
	InserirNovoLogin CliControl = new InserirNovoLogin();
	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					CadastroLinha2 frame = new CadastroLinha2();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public CadastroLinha2() {
		setTitle("TRANSF\u00C1CIL - Cadastro linha de \u00D4nibus2");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 527, 347);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		JLabel lblNome = new JLabel("Nome:");
		lblNome.setFont(new Font("Arial", Font.PLAIN, 11));
		lblNome.setBounds(32, 51, 60, 14);
		contentPane.add(lblNome);
		
		JLabel lblCdigo = new JLabel("C\u00F3digo:");
		lblCdigo.setBounds(32, 76, 60, 14);
		contentPane.add(lblCdigo);
		
		JLabel lblEmpresa = new JLabel("Empresa:");
		lblEmpresa.setFont(new Font("Arial", Font.PLAIN, 11));
		lblEmpresa.setBounds(153, 76, 74, 14);
		contentPane.add(lblEmpresa);
		
		JLabel lblIntinerrio = new JLabel("Intiner\u00E1rio:");
		lblIntinerrio.setBounds(19, 115, 80, 14);
		contentPane.add(lblIntinerrio);
		
		jtfNomeOnibus2 = new JTextField();
		jtfNomeOnibus2.setBounds(82, 48, 397, 20);
		contentPane.add(jtfNomeOnibus2);
		jtfNomeOnibus2.setColumns(10);
		
		jtfCodigo2 = new JTextField();
		jtfCodigo2.setBounds(82, 76, 61, 20);
		contentPane.add(jtfCodigo2);
		jtfCodigo2.setColumns(10);
		
		jtfEmpresa2 = new JTextField();
		jtfEmpresa2.setBounds(207, 73, 273, 20);
		contentPane.add(jtfEmpresa2);
		jtfEmpresa2.setColumns(10);
		
		jtfIntinerario2 = new JTextField();
		jtfIntinerario2.setBounds(82, 101, 397, 43);
		contentPane.add(jtfIntinerario2);
		jtfIntinerario2.setColumns(10);
		
		JButton btnLimpar = new JButton("Limpar");
		btnLimpar.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				jtfNomeOnibus2.setText("");
				jtfCodigo2.setText("");
				jtfEmpresa2.setText("");
				jtfIntinerario2.setText("");
				
				
				
			}
		});
		btnLimpar.setFont(new Font("Arial", Font.PLAIN, 11));
		btnLimpar.setBounds(92, 153, 89, 23);
		contentPane.add(btnLimpar);
		
		btnConfirmar = new JButton("Confirmar");
		btnConfirmar.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				String nomeonibus2 = jtfNomeOnibus2.getText();
				jtfNomeOnibus2.setText("");
				String codigo2 = jtfCodigo2.getText();
				jtfCodigo2.setText("");
				String empresa2 = jtfEmpresa2.getText();
				jtfEmpresa2.setText("");
				String intinerario2 = jtfIntinerario2.getText();
				jtfIntinerario2.setText("");
				
				
				CliControl.InsereDadosOnibus2(nomeonibus2,codigo2, empresa2,intinerario2);
				
				
				
			}
		});
		btnConfirmar.setFont(new Font("Arial", Font.PLAIN, 11));
		btnConfirmar.setBounds(390, 153, 89, 23);
		contentPane.add(btnConfirmar);
		
		lblNewLabel = new JLabel("Cadastrar Linha de Onibus2");
		lblNewLabel.setFont(new Font("Arial", Font.BOLD, 16));
		lblNewLabel.setBounds(10, 11, 411, 14);
		contentPane.add(lblNewLabel);
		
		btnRemover = new JButton("Remover");
		btnRemover.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				
				String nomeonibus2= JOptionPane.showInputDialog(null,"Digite o nome da linha que deseja excluir do sistema: ");
				CliControl.ExcluirLinha2(nomeonibus2);
				
				
			}
		});
		btnRemover.setBounds(412, 275, 89, 23);
		contentPane.add(btnRemover);
		
		btnAnterior = new JButton("Anterior");
		btnAnterior.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				
				CadastroLinhasOnibus retorna5 = new CadastroLinhasOnibus();
				retorna5.setVisible(true);
				CadastroLinha2.this.dispose(); 
				
				
				
			}
		});
		btnAnterior.setFont(new Font("Arial", Font.PLAIN, 11));
		btnAnterior.setBounds(10, 275, 89, 23);
		contentPane.add(btnAnterior);
	}

}
